<?php
require 'user.php';
//require 'geshi.php';
require 'function.php';
if($_POST) {
$_SESSION['viewset']['noline']=$_POST['noline'];

$_SESSION['viewset']['code']=$_POST['code'];
}
if(!$_SESSION['viewset']['code']) $_SESSION['viewset']['code']='UTF-8';
if(file_exists($path=@_decode($_GET['path']))==false) {
header('Content-Type:text/html;charset=UTF-8');
echo <<<HTML
Error：404
HTML;
exit;
}
?>
<?php
header('Content-Type:text/html;charset=UTF-8');
echo <<<HTML
<html>
<head>
<title>文件管理－高亮代码</title>
<style type="text/css">
.big_board{background-color:#009BCE;color:#FFF;}
.board_title{margin-bottom:1px;border:1px solid #09F;}
</style>
</head>
<body>
<div class="big_board"><div class="board_title">爱特文管－路径信息</div></div>
HTML;
echo '<a href="index.php?path='._encode(dirname(_decode($_GET['path']))).'">'.dirname(_decode($_GET['path'])).'</a>/'.basename(_decode($_GET['path']));
echo <<<HTML
<div class="big_board"><div class="board_title">爱特文管－快捷按钮</div></div>
<a href="view.php?path={$_GET['path']}&amp;page=1">分页查看</a>.<a href="view.php?path={$_GET['path']}&amp;read=read">全文查看</a>.<a href="svnview.php?path={$_GET['path']}">SVN追踪</a>.<a href="openfile.php?path={$_GET['path']}">编辑</a>
HTML;
echo '<div class="big_board"><div class="board_title">爱特文管－代码类型</div></div>仅支持php的语法高亮';
echo <<<HTML
<form action="{$_SERVER['REQUEST_URI']}" method="post">
编码(当前{$_SESSION['viewset']['code']}):<select name="code"><option>UTF-8</option><option>GBK</option><option>GB2312</option><option>USC2BE</option><option>USC2LE</option><option>UTF-7</option><option>BASE64</option></select><br/>
不显示行号:<input type="checkbox" name="noline" value="checked=&quot;checked&quot;" {$_SESSION['viewset']['noline']}/><br/>
<input type="submit" name="go" value="确定"/>
</form>
HTML;
echo '<div class="big_board"><div class="board_title">爱特文管－高亮代码</div></div>';

if(@filesize($fn=_decode($_GET['path']))!=0) {
$ht=highlight_string(mb_convert_encoding(file_get_contents($fn),'utf-8',$_SESSION['viewset']['code']),true);
if($_SESSION['viewset']['noline']) echo $ht;
else {
$ht=explode('<br />',$ht);
foreach($ht as $ii=>$hti) {echo $ii+1,'.&nbsp;',$hti,'<br/>';}

}
/*$xread=@file_get_contents(_decode($_GET['path']));
if($_GET['codetype']!=null) {
$codetype=$_GET['codetype'];
} else {
$codetype="php";
}
$source=$xread;
$geshi=new geshi($source,$codetype,'geshi/');
echo nl2br($geshi->parse_code());*/
} else {
echo 'Hello,文件内容为空!';
echo <<<HTML
<form action="{$_SERVER['PHP_SELF']}" method="get">
<input type="hidden" name="path" value="{$_GET['path']}"/>
<input type="hidden" name="read" value="read"/>
编码(当前{$_SESSION['viewset']['code']}):<select name="code"><option>UTF-8</option><option>GBK</option><option>GB2312</option><option>USC2BE</option><option>USC2LE</option><option>UTF-7</option><option>BASE64</option></select><input type="submit" value="确定" name="go"/>
</form>
HTML;
}
echo '<div class="big_board"><div class="board_title">By：Admin@Lspecial.Com</div></div>';
echo '</body></html>';
?>